<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>用户资料审核</title>
	<meta name="decorator" content="default"/>
	<script src="${ctxStatic}/layer/layer.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			layer.config({offset: ['300px', '500px']});
			   function picBig() {
	                var v = document.getElementById('divCenter');
	                v.style.display = "block";
	            }

	            function picClose() {
	                var v = document.getElementById('divCenter');
	                v.style.display = "none";
	            }
	            $(".pic").click(function(){
	            	var url=$(this).data("url");
	            	//页面层
	            	layer.open({
	            	  type: 1,
	            	  title:"资料大图",
	            	  skin: 'layui-layer-rim', //加上边框
	            	  area: ['auto', 'auto'], //宽高
	            	  content: '<img style="min-height: 100px;min-width: 100px;" src="'+url+'"/>'
	            	});
	            });
	            //审核通过或不通过
	            $(".pass,.not_pass").click(function(){
	            	var that=$(this);
	            	var isClear=that.data("status");
	            	var id=$(this).data("id");
	            	 $.ajax({  
	                       type : "POST",  //提交方式  
	                       url : "${ctx}/sys/material/materialUpload/doCheck",//路径  
	                       data : {"id":id,isClear:isClear},//数据，这里使用的是Json格式进行传输  
	                       success : function(data) {//返回数据根据结果进行相应的处理  
	                            if(data){
	                            	layer.alert("操作成功",function(){
	                            		window.location.reload();
	                            	});
	                            	
	                            }else{
	                            	layer.alert("操作失败",-1);
	                            }
	                       }  
	                 });  
	            });
	            //批量审核通过
	            $(".pass_all,.not_pass_all").click(function(){
	            	var that=$(this);
	            	layer.confirm('确认要进行批量审核吗？', {
	            	    btn: ['确认','取消'], //按钮
	            	    shade: false //不显示遮罩
	            	}, function(index){
	            	    // 提交表单的代码，需要你自己写，然后用 layer.close 关闭就可以了，取消可以省略
	            	    layer.close(index);
	            	    var isClear=that.data("status");
		            	var id=$("#member_h1").data("id");
		            	 $.ajax({  
		                       type : "POST",  //提交方式  
		                       url : "${ctx}/sys/material/materialUpload/doCheckBatch",//路径  
		                       data : {"id":id,isClear:isClear},//数据，这里使用的是Json格式进行传输  
		                       success : function(data) {//返回数据根据结果进行相应的处理  
		                            if(data){
		                            	layer.alert("操作成功",function(){
		                            		window.location.reload();
		                            	});
		                            	
		                            }else{
		                            	layer.alert("操作失败",-1);
		                            }
		                       }  
		                 });
	            	});
	            });
	            
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/sys/loan/customPay/">客户申请记录列表</a></li>
		<li class="active"><a href="${ctx}/sys/material/materialUpload/checkFormPage?id=${member.id}">用户资料清晰度审核</a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="member" action="${ctx}/sys/member/member/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<div class="container">
		<div class="row">
			<div class="col-md-2 col-md-offset-5" style="text-align: center;">
				<h1 id="member_h1" data-id="${member.id}">${member.nickname}的资料列表</h1>
		    </div>
		</div>

				<div class="row">
					<table class="table">
						  <thead>
						    <tr>
								<th>所属资料</th>
						  	  <th>资料类别名</th>
						      <th>是否清晰</th>
						      <th>资料</th>
						      <th>审核清晰度</th>
						    </tr>
						  </thead>
						  <tbody>
						  <c:choose>
							  <c:when test="${empty muList || fn:length(muList)==0 }">
								  <tr>
									  <td colspan="4">该用户暂无上传资料 </td>
								  </tr>
							  </c:when>
							  <c:otherwise>
								  <c:forEach items="${muList}" var="mu">
									  <c:if test="${mu.typeId !='1'}">
										  <tr>
											  <td>${mu.parentTypeName}</td>
											  <td>${mu.typeName}</td>
											  <td>
												  <c:choose>
													  <c:when test="${empty mu.url}"><span style="color:blue">不是图片类型</span></c:when>
													  <c:when test="${empty mu.isClear}"><span style="color:blue">未审核</span></c:when>
													  <c:when test="${mu.isClear==true}"><span style="color:green">已审核为：清晰</span></c:when>
													  <c:when test="${mu.isClear==false}"><span style="color:red">已审核为：不清晰</span></c:when>
													  <c:otherwise></c:otherwise>
												  </c:choose>
											  </td>
											  <td>
												<c:choose>
													  <c:when test="${empty mu.url}">
														  ${mu.value}
													  </c:when>
													  <c:otherwise>
														  <a class="pic" href="javascript:void(0)" data-url="${mu.url}"><img alt="资料图片" src="${mu.url}"   style="width: 50px;height: 50px;"></a>
													  </c:otherwise>
												</c:choose>
											  </td>
											  <td>
												  <c:choose>
													  <c:when test="${empty mu.url}"></c:when>
													  <c:when test="${empty mu.isClear}">	<shiro:hasPermission name="sys:loan:customPay:docheckmaterialclear"><button type="button" data-id="${mu.id}" data-status="1" class="btn  btn-primary pass">审核为清晰</button> </shiro:hasPermission></c:when>
													  <c:when test="${mu.isClear==true}">	<shiro:hasPermission name="sys:loan:customPay:docheckmaterialclear"><button type="button" data-id="${mu.id}" data-status="0" class="btn  btn-danger not_pass">审核为不清晰</button></shiro:hasPermission> </c:when>
													  <c:when test="${mu.isClear==false}">	<shiro:hasPermission name="sys:loan:customPay:docheckmaterialclear"><button type="button" data-id="${mu.id}" data-status="1" class="btn  btn-primary pass">审核为清晰</button> </shiro:hasPermission></c:when>
													  <c:otherwise></c:otherwise>
												  </c:choose>
											  </td>
										  </tr>
									  </c:if>
								  </c:forEach>
							  </c:otherwise>
						  </c:choose>
						  </tbody>
						</table>
					</div>
					
					<div class="row">
						<div class="col-md-2 col-md-offset-5" style="text-align: center;">
							<shiro:hasPermission name="sys:member:member:edit"><input id="btnSubmit" class="btn btn-primary pass_all" data-status="1" value="批量审核为清晰"/>&nbsp;
							<input id="btnSubmit" class="btn btn-danger not_pass_all" data-status="0"  value="批量审核为不清晰"/>
							</shiro:hasPermission>
							<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
					    </div>
					</div>

		</div>
		
	</form:form>
</body>
</html>